if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sp_HangHoa_Update]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[sp_HangHoa_Update]
GO
CREATE PROC [sp_HangHoa_Update]
	@MaHang					nvarchar(30),
	@TenHang				nvarchar(50),
	@MaNhomHang				int,
	@Barcode				nvarchar(500),
	@MoTa					nvarchar(2000),
	@Hinh					nvarchar(500),
	@Thue					int,
	@ChietKhau				int,
	@GiaNhap				float,
	@GiaBanSi				float,
	@GiaBanLe				float,
	@MaDonViQuiDoi			int,
	@DinhMucTon				float,
	@GhiChu					nvarchar(2000),
	@id						int
AS
BEGIN
	DECLARE @Ngay_cap_nhat_cuoi datetime
		SET @Ngay_cap_nhat_cuoi = getdate()
		
	UPDATE HangHoa
		SET
					Ma_hang = @MaHang,
					Ten = @TenHang,
					Ma_nhom_hang = @MaNhomHang,
					Ghi_chu = @GhiChu,
					Ma_don_vi_qui_doi = @MaDonViQuiDoi,
					Thue = @Thue,
					Chiet_khau = @ChietKhau,
					Gia_nhap = @GiaNhap,
					Gia_ban_si = @GiaBanSi,
					Gia_ban_le = @GiaBanLe,
					Ton_dinh_muc = @DinhMucTon,
					Mo_ta = @MoTa,
					Hinh = @Hinh,
					Barcode_new = @Barcode,
					Ngay_cap_nhat_cuoi = @Ngay_cap_nhat_cuoi
		WHERE ID = @id
END
